package components;

import components.PumpController.BatteryStatus;

/* Manages the battery status */
public class PowerManager {

	private int batteryLevel;
	private BatteryStatus bs;
	
	public PowerManager() {
		batteryLevel = 100;
		bs = BatteryStatus.Normal;
	}
	
	public void decrementBatteryLevel() {
		--batteryLevel;
		updateBatteryStatus();
	}
	
	public void setBatteryLevel(int batteryLevel) {
		this.batteryLevel = batteryLevel;
		updateBatteryStatus();
	}
	
	public int getBatteryLevel() {
		return batteryLevel;
	}
	
	public BatteryStatus getBatteryStatus() {
		return bs;
	}
	
	private void updateBatteryStatus() {
		if (batteryLevel <= 1)
			bs = BatteryStatus.Depleted;
		else if (batteryLevel <= 15)
			bs = BatteryStatus.Low;
		else if (batteryLevel <= 30)
			bs = BatteryStatus.Warning;
		else
			bs = BatteryStatus.Normal;
	}
}
